package cn.sola.shiro.tutotisl.util;

import java.text.SimpleDateFormat;

import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;


/**
 * @author: kangxiaohui
 * @date：2017年12月27日 下午3:18:49
 * @version 1.0 
 * 
 */
public class JsonUtils {

	public static String objectToJsonString(Object object) {
		String jsonArray = "";
		ObjectMapper objectMapper = new ObjectMapper();
		SimpleModule simpleModule = new SimpleModule("sola", Version.unknownVersion());
		simpleModule.addSerializer(Long.class, ToStringSerializer.instance);
		simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance);
		objectMapper.registerModule(simpleModule);
		try {
			jsonArray = objectMapper.writeValueAsString(object);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return jsonArray.toString();
	}
}
